import java.util.*;
import java.lang.*;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-03-30
 * Time: 19:07
 */
public class Test {

    public static String setstring(String str) {
        // write code here
        int[] nums = new int['z' - 'A' + 1];
        int len = 0;
        char[] str1 = new char[str.length()];
        for(int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if(nums[ch - 'A'] == 0) {
                str1[len++] = ch;
            }
            nums[ch - 'A']++;
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < len; i++) {
            stringBuilder.append(str1[i]);
        }
        String ans = new String(stringBuilder);

        return ans;
    }
    public void merge(int A[], int m, int B[], int n) {
        for(int i = m, j = 0; i < m + n; i++, j++) {
            A[i] = B[j];
        }
        Arrays.stream(A).sorted();
        for(int i = 0; i < m + n - 1; i++) {
            for(int j = 0; j < m + n - i - 1; j++) {
                if(A[i] > A[i + 1]){
                    int t = A[i];
                    A[i] = A[i + 1];
                    A[i + 1] = t;
                }
            }
        }
    }
    public static String setstring1(String str) {
        int[] nums = new int['z' - 'A' + 1];
        StringBuilder stringBuilder = new StringBuilder();
        for(int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if(nums[ch - 'A'] == 0) {
                stringBuilder.append(ch);
            }
            nums[ch - 'A']++;
        }
        return stringBuilder.toString();
    }
    public void merge1(int A[], int m, int B[], int n) {
        int i = m - 1;
        int j = n - 1;
        int k = m + n - 1;
        while(i>=0||j>=0) {
            if(A[i] <= B[j]) {
                A[k] = B[j];
                j--;
            } else {
                A[k] = A[i];
                i--;
            }
            k--;
        }
    }
    public static void main(String[] args) {
        String str = setstring1("BAabB");
        System.out.println(str);
        //A a = new A();
        //a.test(5);
    }
}
class A {
    private int a;

    private A(int a) {
        this.a = a;
    }
    public void test (int n) {
        A t = new A(n);
    }
}
